package com.ftd.controller;

import com.alibaba.fastjson.JSONArray;
import com.ftd.DBConnection.DBConnection;
import com.ftd.model.Ebook;
import com.ftd.model.Index;
import com.ftd.model.Mark;
import com.ftd.viewmodel.MapResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by apple on 16/7/31.
 */
@RestController
public class IndexViewController {
    @RequestMapping("getIndexJson.do")
    @ResponseBody
    public List<MapResult>  getIndexJson(){
        List<MapResult> mapList = new ArrayList<MapResult>();
        ArrayList list = (ArrayList) DBConnection.select3("indexTable");
        for (int i = 0; i < list.size();i++) {
            Index index = (Index)list.get(i);
            MapResult mapResult = new MapResult();
            mapResult.put("topImageUrl", index.getItImageUrl());
            mapResult.put("bottomImageUrl", index.getIbImageUrl());
            mapList.add(mapResult);
        }
        return mapList;
    }
    @RequestMapping(value = "indexView")
    public String indexView(){
        return "indexView";
    }
}
